Connecting Using a Connection String

If you want to use a connection string for connecting to a database, or if your application requires it, you must specify either a DSN (data source name) or a DSN-less connection in the string. The difference is whether you use the DSN= or the DRIVER= keyword in the connection string, as described in the ODBC specification. A DSN connection string tells the driver where to find the default connection information. Optionally, you may specify attribute=value pairs in the connection string to override the default values stored in the data source.

If your application requires a connection string to connect to a data source, you must specify the data source name that tells the driver which data source to use for the default connection information. Optionally, you may specify attribute=value pairs in the connection string to override the default values stored in the data source.

The DSN connection string has the form::

DSN=data_source_name[;attribute=value[;attribute=value]...] 

For example, a connection string for SequeLink may look like this:

DSN=Accounting;DB=EMP;UID=JOHN;PWD=XYZZY 

or

DSN=Accounting;DB="X:IV;EMP";UID=JOHN;PWD=XYZZY 

NOTE: If the database name (DB) contains a semicolon (;), you must place the name in quotes, as shown in the preceding example.

The DSN-less connection string specifies a driver instead of a data source. All connection information must be entered in the connection string because there is no data source storing the information.

The DSN-less connection string has the form:

DRIVER=[{]driver_name[}][;attribute=value[;attribute=value] 
...] 

NOTE: Empty string is the default value for attributes that use a string value unless otherwise noted.

A DSN-less connection string must provide all necessary connection information:

DRIVER=DataDirect SequeLink 6.0;DB=Emp;UID=JOHN;PWD=XYZZY 

See "DSN-less Connections in Linux and UNIX" for more information about using DSN-less connections.

DSN-less Connections in Linux and UNIX

Connections to a data source can be made via a connection string without referring to a data source name (DSN-less connections). This is accomplished by specifying the "DRIVER=" instead of the "DSN=" keyword in a connection string, as outlined in the ODBC specification. For this to work on Linux and UNIX, a file called odbcinst.ini must exist when the driver encounters DRIVER= in a connection string.

By default, Setup installs a sample odbcinst.ini file in the same location as the sample odbc.ini file, which is in the product installation directory. See "Configuring the System Information File" for an explanation of the odbc.ini file. The environment variable ODBCINST, recognized by the DataDirect SequeLink for ODBC driver, must be set to point to the fully qualified path name of the odbcinst.ini file.

For example, to point to the default location of the file in the C shell, you set this variable as follows:

setenv ODBCINST /opt/sl60/client/odbcinst.ini 

In the Bourne or Korn shell, you would set it as:

ODBCINST=/opt/sl60/client/odbcinst.ini;export ODBCINST 

If the ODBCINST variable is not set, the driver looks in the user's home directory for a file named odbcinst.ini. If the driver does not find the file, it returns the message:

HY000 - "ODBCINST.INI is not available in the directory 
pointed to by the ODBCINST environment variable (or the 
current user's HOME directory) and therefore DSN-Less 
connections cannot be made." 

The following is a sample odbcinst.ini.

[ODBC Drivers] 
DataDirect SequeLink 6.0 = Installed 
[DataDirect SequeLink 6.0] 
APILevel=1 
ConnectFunctions=YYN 
Driver=ivslk22.so 
DriverODBCVer=3.52 
FileUsage=0 
SQLLevel=1